<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                        <a-form-item label="采购入库单号">
                            <a-input placeholder="请输入" v-model="queryParam.orderNo" />
                        </a-form-item>
                    </a-col>
                    <a-col :xl="8" :lg="9" :md="10" :sm="24">
                        <a-form-model-item label="业务员"  prop="operator"
                            ref="operatorFmi">
                            <j-select-user-by-dep v-model="queryParam.operator" :multi="false"
                                @change="onOperatorChange" />
                        </a-form-model-item>
                    </a-col>
            <!--         <template v-if="toggleSearchStatus">
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="单据主题">
                                <a-input placeholder="请输入" v-model="queryParam.subject" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="供应商">
                                <j-search-select-tag v-model="queryParam.supplierId" :async="true"
                                    dict="bas_supplier,aux_name,id" placeholder="请选择" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="4" :lg="6" :md="7" :sm="24">
                            <a-form-item label="单据阶段">
                                <j-dict-select-tag v-model="queryParam.billStage" dictCode="x_bill_stage" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="4" :lg="6" :md="7" :sm="24">
                            <a-form-item label="已生效">
                                <j-dict-select-tag v-model="queryParam.isEffective" dictCode="yn" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="4" :lg="6" :md="7" :sm="24">
                            <a-form-item label="已关闭">
                                <j-dict-select-tag v-model="queryParam.isClosed" dictCode="yn" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="4" :lg="6" :md="7" :sm="24">
                            <a-form-item label="已作废">
                                <j-dict-select-tag v-model="queryParam.isVoided" dictCode="yn" />
                            </a-form-item>
                        </a-col>
                    </template> -->

                    <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                        <a-col :md="6" :sm="24">
                            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                            <a-button @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
                            <a @click="handleToggleSearch" style="margin-left: 8px">
                                {{ toggleSearchStatus ? '收起' : '展开' }}
                                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                            </a>
                        </a-col>
                    </span>

                </a-row>
            </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
            <a-button @click="myHandleAdd" type="link" icon="plus">新增</a-button>
            <a-button type="link" icon="download" @click="handleExportXls('出入库单')">导出</a-button>
            <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
                :action="importExcelUrl" @change="handleImportExcel">
                <a-button type="link" icon="import">导入</a-button>
            </a-upload>

            <a-dropdown v-if="selectedRowKeys.length > 0">
                <a-menu slot="overlay">
                    <a-menu-item :disabled="!isBatchEnabled('delete')" key="1" @click="batchDel">删除</a-menu-item>
                    <a-menu-item :disabled="!isBatchEnabled('close')" key="2" @click="batchClose">关闭</a-menu-item>
                    <a-menu-item :disabled="!isBatchEnabled('unclose')" key="3" @click="batchUnclose">反关闭</a-menu-item>
                </a-menu>
                orderedQty<a-button type="link" style="margin-left: 8px">批量操作<a-icon type="down" /></a-button>
            </a-dropdown>
            <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
                selectedRowKeys.length
                }}</a>项
            <a v-if="selectedRowKeys.length > 0" style="margin-left: 12px" @click="onClearSelected">清空</a>

            <table-columns-setter v-model="columns" style="float: right;" />
        </div>

        <!-- table区域-begin -->
        <div>
            <a-table ref="table" size="middle" bordered rowKey="id" :scroll="{ x: 800 }" :columns="columns"
                :dataSource="dataSource" :pagination="ipagination" :loading="loading"
                :rowSelection="{ selectedRowKeys: selectedRowKeys, columnWidth: 40, onChange: onSelectChange }"
                :components="drag(columns)" @change="handleTableChange">

                <a slot="orderNo" @click="myHandleDetail(record)" slot-scope="text, record">{{ text }}</a>

                <!-- <span slot="action" slot-scope="text, record">
                    <a  @click="myHandleEdit(record)">编辑</a>
                    <a-divider type="vertical" />
                    <a-dropdown>
                        <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                        <a-menu slot="overlay">
                            <a-menu-item  key="1">
                                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">删除</a-popconfirm>
                            </a-menu-item>
                            <a-menu-item key="9" @click="handlePrint(record.id)">打印</a-menu-item>
                        </a-menu>
                    </a-dropdown>
                </span> -->

            </a-table>
        </div>

        <mat-in-modal ref="modalForm" @ok="modalFormOk" @print="handlePrint" />
    </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import matInModal from './modules/matInModal'
import TableColumnsSetter from '../common/components/TableColumnsSetter'
import { OrderListMixin } from '../common/mixins/OrderListMixin'
import { ListMixin } from '../common/mixins/ListMixin'
export default {
    name: "OtherInList",
    mixins: [JeecgListMixin, OrderListMixin,ListMixin],
    components: { TableColumnsSetter, matInModal },

    data() {
        return {
            description: '原材料库存',
            billReportId: '731058600320741376',
            queryParam: {
                isVoided: 0,
            },

            // 表头
            // 表头
            columns: [
                {
                    title: '#',
                    dataIndex: '',
                    key: 'rowIndex',
                    fixed: 'left',
                    width: 40,
                    align: "center",
                    customRender: (t, r, index) => parseInt(index) + 1
                },
                {
                    title: '物料',
                    fixed: 'left',
                    width: 260,
                    align: "center",
                    dataIndex: 'materialId_dictText',
                    sorter: true
                },
                {
                    title: '入库数量',
                    fixed: 'left',
                    width: 100,
                    align: "center",
                    dataIndex: 'qty',
                    sorter: true
                },
                {
                    title: '单位',
                    fixed: 'left',
                    width: 50,
                    align: "center",
                    dataIndex: 'unitId_dictText',
                      sorter: true
                },
                {
                    title: '仓库',
                    fixed: 'left',
                    width: 260,
                    align: "center",
                    dataIndex: 'warehouseId_dictText',
                    sorter: true
                },
                {
                    title: '创建人',
                    width: 100,
                    align: "center",
                    dataIndex: 'createBy'
                },
                {
                    title: '创建时间',
                    align: "center",
                    dataIndex: 'createTime',
                    customRender: t => !t ? "" : (t.length > 10 ? t.substr(0, 10) : t)
                },
                {
                    title: '更新人',
                     width: 100,
                    align: "center",
                    dataIndex: 'updateBy'
                },
                {
                    title: '更新时间',
                    align: "center",
                    dataIndex: 'updateTime',
                    customRender: t => !t ? "" : (t.length > 10 ? t.substr(0, 10) : t)
                },

               /*  {
                    title: '操作',
                    dataIndex: 'action',
                    fixed: 'right',
                    width: 120,
                    align: "center",
                    scopedSlots: {
                        filterDropdown: 'filterDropdown',
                        filterIcon: 'filterIcon',
                        customRender: 'action'
                    },
                } */
            ],
            url: {
                list: "/wr/materialRawStock/list",
                delete: "/stock/stkIo/delete",
                deleteBatch: "/stock/stkIo/deleteBatch",
                close: "/stock/stkIo/close",
                closeBatch: "/stock/stkIo/closeBatch",
                unclose: "/stock/stkIo/unclose",
                uncloseBatch: "/stock/stkIo/uncloseBatch",
                exportXlsUrl: "/stock/stkIo/exportXls/199",
                importExcelUrl: "stock/stkIo/importExcel/199",
            },
            dictOptions: {},
        }
    },

    methods: {
        initDictConfig() { }
    }

}
</script>

<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '../common/less/List.less';
</style>
